package com.itheima.edu.info.manager.day9;

public class Student1 implements Comparable<Student1> {
    private String name;
    private int yuWen;
    private int shuXue;
    private int yingYU;

    public Student1() {
    }

    public Student1(String name, int yuWen, int shuXue, int yingYU) {
        this.name = name;
        this.yuWen = yuWen;
        this.shuXue = shuXue;
        this.yingYU = yingYU;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYuWen() {
        return yuWen;
    }

    public void setYuWen(int yuWen) {
        this.yuWen = yuWen;
    }

    public int getShuXue() {
        return shuXue;
    }

    public void setShuXue(int shuXue) {
        this.shuXue = shuXue;
    }

    public int getYingYU() {
        return yingYU;
    }

    public void setYingYU(int yingYU) {
        this.yingYU = yingYU;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Student1 student1 = (Student1) o;

        if (yuWen != student1.yuWen) return false;
        if (shuXue != student1.shuXue) return false;
        if (yingYU != student1.yingYU) return false;
        return name != null ? name.equals(student1.name) : student1.name == null;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + yuWen;
        result = 31 * result + shuXue;
        result = 31 * result + yingYU;
        return result;
    }

    @Override
    public String toString() {
        return "Student1{" +
                "name='" + name + '\'' +
                ", yuWen=" + yuWen +
                ", shuXue=" + shuXue +
                ", yingYU=" + yingYU +
                '}';
    }
int sum=yingYU+shuXue+yuWen;//赋值时并不会执行sum

    public  int getsum(){
        return yuWen+shuXue+yingYU;
    }

    @Override
    public int compareTo(Student1 s) {
        return this.getsum()-s.getsum();
    }
}

